//
//  HJRepairGroupViewController.m
//  GAMCAfterSales
//
//  Created by 贺佳 on 2018/7/30.
//  Copyright © 2018年 glendale. All rights reserved.
//

#import "HJRepairGroupViewController.h"
#import "popContentViewController.h"
#import "DDPopoverBackgroundView.h"

#import "HJRepairGroupSectionView.h"
#import "HJRepairGroupHeaderView.h"
#import "HJRepairtGroupMainCell.h"
#import "HJCommonViewCell.h"
#import "HJRepairtGroupPartViewCell.h"

#import "HJRepairtGroupSearchRequest.h"
#import "HJRepairtGroupModel.h"
#import "HJCommonTitleCellModel.h"
#import "HJCommonModel.h"


@interface HJRepairGroupViewController ()<UITableViewDelegate,UITableViewDataSource,HJRepairGroupHeaderViewDelegate,HJRepairtGroupMainCellDelegate,HJRepairGroupSectionViewDelegate,ContentViewControllerDelegate>{
    
    //下拉菜单属性
    popContentViewController *contentCon;
    UIPopoverController *popCon;
}
/**
 主tableView
 */
@property(nonatomic,strong)UITableView*mainTableView;
/**
维修项目tableView
 */
@property(nonatomic,strong)UITableView*repairTableView;
/**
 配件
 */
@property(nonatomic,strong)UITableView*partTableView;
/**
 搜索视图
 */
@property(nonatomic,strong)HJRepairGroupHeaderView*headerView;
/**
 分组数组
 */
@property(nonatomic,strong)NSArray*sectionAry;
/**
 主数据
 */
@property(nonatomic,strong)NSMutableArray*mainDataAry;
/**
 维修项目数据
 */
@property(nonatomic,strong)NSMutableArray*repairtDataAry;
/**
 零件项目数据
 */
@property(nonatomic,strong)NSMutableArray*partsDataAry;
/**
 保养车型项目数据
 */
@property(nonatomic,strong)NSMutableArray*modelDataAry;
/**
 保养车辆项目数据
 */
@property(nonatomic,strong)NSMutableArray*vehicleAry;
/**
 分割线
 */
@property(nonatomic,weak)UIImageView *lineView;
/**
 请求模型
 */
@property(nonatomic,strong)HJRepairtGroupSearchRequest*requestModel;
/**
 数据源模型
 */
@property(nonatomic,strong)HJRepairtGroupModel*groupModel;
/**
 工时单价缓存数据
 */
@property(nonatomic,strong)NSMutableArray*labourPrices;
@end

@implementation HJRepairGroupViewController
/** 工时单价 */
-(NSMutableArray *)labourPrices{
    if (_labourPrices == nil) {
        NSMutableArray *arr = [HJLocalDataManager sharedInstance].cacheDict[@"TM_LABOUR_PRICE"];
        _labourPrices=[HJCommonModel mj_objectArrayWithKeyValuesArray:arr];
    }
    return _labourPrices;
}
-(NSMutableArray *)modelDataAry
{
    if (!_modelDataAry) {
        _modelDataAry=[NSMutableArray array];
    }
    return _modelDataAry;
}
-(NSMutableArray *)vehicleAry
{
    if (!_vehicleAry) {
        _vehicleAry=[NSMutableArray array];
    }
    return _vehicleAry;
}
-(HJRepairtGroupSearchRequest *)requestModel
{
    if (!_requestModel) {
        _requestModel=[HJRepairtGroupSearchRequest new];
    }
    return _requestModel;
}
-(NSArray *)sectionAry
{
    if (!_sectionAry) {
        NSString*path=[[NSBundle mainBundle] pathForResource:@"repairtGroup.plist" ofType:nil];
        _sectionAry=[NSArray arrayWithContentsOfFile:path];
    }
    return _sectionAry;
}
-(NSMutableArray *)mainDataAry
{
    if (!_mainDataAry) {
        _mainDataAry=[NSMutableArray array];
    }
    return _mainDataAry;
}
-(NSMutableArray *)repairtDataAry
{
    if (!_repairtDataAry) {
        _repairtDataAry=[NSMutableArray array];
    }
    return _repairtDataAry;
}
-(NSMutableArray *)partsDataAry
{
    if (!_partsDataAry) {
        _partsDataAry=[NSMutableArray array];
    }
    return _partsDataAry;
}
-(HJRepairGroupHeaderView *)headerView
{
    if (!_headerView) {
        _headerView=[[HJRepairGroupHeaderView alloc]initWithFrame:CGRectMake(40,CGRectGetMaxY(self.lineView.frame), self.view.mj_w-80,70)];
        _headerView.delegate=self;
       
    }
    return _headerView;
}
-(UITableView *)partTableView
{
    if (!_partTableView) {
        _partTableView=[[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        _partTableView.delegate=self;
        _partTableView.dataSource=self;
        _partTableView.estimatedRowHeight=0;
        _partTableView.estimatedSectionFooterHeight=0;
        _partTableView.estimatedSectionHeaderHeight=0;
        _partTableView.backgroundColor=[UIColor clearColor];
        [self.view addSubview:_partTableView];
        WEAKSELF;
        [_partTableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(weakSelf.mainTableView);
            make.top.mas_equalTo(weakSelf.repairTableView.mas_bottom);
            make.bottom.mas_equalTo(weakSelf.view);
        }];
    }
    return _partTableView;
}
-(UITableView *)repairTableView
{
    if (!_repairTableView) {
        _repairTableView=[[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        _repairTableView.delegate=self;
        _repairTableView.dataSource=self;
        _repairTableView.estimatedRowHeight=0;
        _repairTableView.estimatedSectionFooterHeight=0;
        _repairTableView.estimatedSectionHeaderHeight=0;
        _repairTableView.backgroundColor=[UIColor clearColor];
        [self.view addSubview:_repairTableView];
        WEAKSELF;
        [_repairTableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(weakSelf.mainTableView);
            make.top.mas_equalTo(weakSelf.mainTableView.mas_bottom);
            make.height.mas_equalTo(weakSelf.view).multipliedBy(0.25);
        }];
    }
    return _repairTableView;
}
-(UITableView *)mainTableView
{
    if (!_mainTableView) {
        _mainTableView=[[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        _mainTableView.delegate=self;
        _mainTableView.dataSource=self;
        _mainTableView.estimatedRowHeight=0;
        _mainTableView.estimatedSectionFooterHeight=0;
        _mainTableView.estimatedSectionHeaderHeight=0;
        _mainTableView.backgroundColor=[UIColor clearColor];
         [self.view addSubview:_mainTableView];
        WEAKSELF;
        [_mainTableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.mas_equalTo(weakSelf.view).inset(40);
            make.top.mas_equalTo(weakSelf.headerView.mas_bottom);
            make.bottom.mas_equalTo(weakSelf.view.mas_centerY);
        }];
    }
    return _mainTableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUI];
}
-(void)setUI{
    self.view.backgroundColor=[UIColor whiteColor];
    //返回按钮
    UIButton*homeBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
    UIImage*img=[UIImage imageNamed:@"返回.png"];
    [homeBackButton setImage:img forState:UIControlStateNormal];
    CGFloat h=40;
    CGFloat w=h/img.size.height*img.size.width;
    [homeBackButton setFrame:CGRectMake(60, 42, w, h)];
    [homeBackButton addTarget:self action:@selector(clickBack) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:homeBackButton];
    
    //视图标题
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(homeBackButton.frame)+20, 45, 200, 40)];
    titleLabel.text = @"成组录入";
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.font = [UIFont systemFontOfSize:30];
    [self.view addSubview:titleLabel];
    
    UIImageView *lineView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 1000, 11)];
    lineView.image = [UIImage imageNamed:@"渐变分割线.png"];
    [self.view addSubview:lineView];
    self.lineView=lineView;
    
    
    WEAKSELF;
    UIButton*saveBtn=[[UIButton alloc]init];
    [self.view addSubview:saveBtn];
    saveBtn.backgroundColor=[UIColor redColor];
    [saveBtn setTitle:@"保存" forState:UIControlStateNormal];
    saveBtn.layer.cornerRadius=8;
    saveBtn.layer.masksToBounds=YES;
    [saveBtn addTarget:self action:@selector(clickSave) forControlEvents:UIControlEventTouchUpInside];
    [saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 35));
        make.centerY.mas_equalTo(homeBackButton);
        make.right.mas_equalTo(weakSelf.view).inset(40);
    }];
    //
    UIButton*searchBtn=[[UIButton alloc]init];
    [self.view addSubview:searchBtn];
    searchBtn.backgroundColor=[UIColor redColor];
    [searchBtn setTitle:@"搜索" forState:UIControlStateNormal];
    searchBtn.layer.cornerRadius=8;
    searchBtn.layer.masksToBounds=YES;
    [searchBtn addTarget:self action:@selector(clickSearch) forControlEvents:UIControlEventTouchUpInside];
    [searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 35));
        make.centerY.mas_equalTo(homeBackButton);
        make.right.mas_equalTo(saveBtn.mas_left).inset(40);
    }];
     [self.view addSubview:self.headerView];
   
}
-(void)clickSave{
    NSMutableArray*ary=[NSMutableArray array];
    for (HJRepairtGroupTM_PACKAGEModel*model in self.groupModel.TM_PACKAGE) {
        if (model.isSelect) {
            [ary addObject:model];
        }
    }
    if (!ary.count) {
        ALERT(@"请选择维修组合");
        return;
    }
    for (HJRepairtGroupTM_PACKAGE_LABOURModel*TM_PACKAGE_LABOURModel in self.repairtDataAry) {
        if (!TM_PACKAGE_LABOURModel.LABOUR_PRICE.length) {
            ALERT(@"请选择工时单价");
            return;
        }
    }
    if (self.returnRepairtGroup) {
       
        self.returnRepairtGroup(self.repairtDataAry,self.partsDataAry);
    }
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)clickSearch{
    [SVProgressHUD showWithStatus:@"正在加载"];
    WEAKSELF;
    [MyAFNetWorkManager postWithParam:self.requestModel.mj_keyValues andAction:@"QUERY_PACKAGE_DETAIL_FOR_PAD" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
        [SVProgressHUD dismiss];
        if (error) {
            [SVProgressHUD showErrorWithStatus:@"获取数据失败"];
            return;
        }else{
        weakSelf.groupModel=[HJRepairtGroupModel mj_objectWithKeyValues:obj];
            //计算配件金额
            for (HJRepairtGroupTM_PACKAGE_PARTModel*TM_PACKAGE_PARTModel in weakSelf.groupModel.TM_PACKAGE_PART) {
                TM_PACKAGE_PARTModel.PART_SALES_AMOUNT=[NSString stringWithFormat:@"%.2f",TM_PACKAGE_PARTModel.PART_QUANTITY*[TM_PACKAGE_PARTModel.PART_SALES_PRICE floatValue]];
            }
            if (weakSelf.groupModel.SUCCESS!=1) {
                ALERT(weakSelf.groupModel.MSG);
            }
            [weakSelf.repairtDataAry removeAllObjects];
            [weakSelf.partsDataAry removeAllObjects];
            [weakSelf.modelDataAry removeAllObjects];
            [weakSelf.vehicleAry removeAllObjects];
            [weakSelf.mainTableView reloadData];
        }
    }];
}
-(void)clickBack{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark --UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView==self.mainTableView) {
       return self.groupModel.TM_PACKAGE.count;
    }else if (tableView==self.repairTableView){
        return self.repairtDataAry.count;
    }else if(tableView==self.partTableView){
        return self.partsDataAry.count;
    }else {
       return 0;
    }
    
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView==self.mainTableView) {
        HJRepairtGroupMainCell*cell=[HJRepairtGroupMainCell cellWithTable:tableView];
        cell.row=indexPath.row;
        cell.delegate=self;
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.TM_PACKAGEModel=self.groupModel.TM_PACKAGE[indexPath.row];
        return cell;
    }else if (tableView==self.repairTableView){
        HJRepairtGroupPartViewCell*cell=[HJRepairtGroupPartViewCell cellWithTable:tableView];
        cell.TM_PACKAGE_LABOURModel=self.repairtDataAry[indexPath.row];
        
        return cell;
    }else{
        HJCommonViewCell*cell=[HJCommonViewCell cellWithTable:tableView];
            //设置配件项目
            cell.contentAry= [self setUpTM_PACKAGE_PART:indexPath];
        return cell;
    }
   
}
-(NSArray*)setUpTM_PACKAGE_VEHICLE:(NSIndexPath*)indexPath{
    NSMutableArray*ary=[NSMutableArray array];
    HJRepairtGroupTM_PACKAGE_VEHICLEModel*TM_PACKAGE_VEHICLEModel=self.groupModel.TM_PACKAGE_VEHICLE[indexPath.row];
    NSArray*titleAry=self.sectionAry[indexPath.section];
        for (int i=0; i<titleAry.count; i++) {
            HJCommonTitleCellModel*model=[HJCommonTitleCellModel new];
        switch (i) {
            case 0:
                model.flex=1;
                model.content=[NSString stringWithFormat:@"%zd",indexPath.row];
                break;
            case 1:
                model.flex=9;
                model.content=TM_PACKAGE_VEHICLEModel.VIN;
                break;
                
            default:
                break;
        }
        [ary addObject:model];
        }
    return [ary copy];
}
-(NSArray*)setUpTM_PACKAGE_MODEL:(NSIndexPath*)indexPath{
   
    NSMutableArray*ary=[NSMutableArray array];
    HJRepairtGroupTM_PACKAGE_MODELModel*TM_PACKAGE_MODELModel=self.modelDataAry[indexPath.row];
        NSArray*titleAry=self.sectionAry[indexPath.section];
        for (int i=0; i<titleAry.count; i++) {
            HJCommonTitleCellModel*model=[HJCommonTitleCellModel new];
        switch (i) {
            case 0:
                 model.flex=1;
                model.content=[NSString stringWithFormat:@"%zd",indexPath.row];
                break;
            case 1:
                 model.flex=4.5;
                model.content=TM_PACKAGE_MODELModel.GROUP_CODE;
                break;
            case 2:
                model.flex=4.5;
                model.content=TM_PACKAGE_MODELModel.GROUP_CODE;
                break;
                
            default:
                break;
        }
        [ary addObject:model];
        }
    return [ary copy];
}
-(NSArray*)setUpTM_PACKAGE_PART:(NSIndexPath*)indexPath{
   
    NSMutableArray*ary=[NSMutableArray array];
    HJRepairtGroupTM_PACKAGE_PARTModel*TM_PACKAGE_PARTModel=self.partsDataAry[indexPath.row];
        NSArray*titleAry=self.sectionAry[indexPath.section];
        for (int i=0; i<titleAry.count; i++) {
            HJCommonTitleCellModel*model=[HJCommonTitleCellModel new];
            model.flex=1;
            switch (i) {
                case 0:
                    model.content=TM_PACKAGE_PARTModel.STORAGE_CODE;
                    break;
                case 1:
                    model.content=TM_PACKAGE_PARTModel.PART_NO;
                    break;
                case 2:
                    model.content=TM_PACKAGE_PARTModel.PART_NAME;
                    break;
                case 3:
                    model.content=[NSString stringWithFormat:@"%zd",TM_PACKAGE_PARTModel.PART_QUANTITY];
                    break;
                    
                default:
                    break;
            }
            [ary addObject:model];
        }

    return [ary copy];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 40.0f;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.1f;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    
    static NSString*ID=@"headerView";
    HJRepairGroupSectionView*sectionView=[tableView dequeueReusableHeaderFooterViewWithIdentifier:ID];
    if (!sectionView) {
        sectionView=[[HJRepairGroupSectionView alloc]initWithReuseIdentifier:ID];
        sectionView.delegate=self;
    }
    if (tableView==self.mainTableView) {
        sectionView.titleAry=self.sectionAry[0];
        sectionView.flexAry=@[@"1",@"1",@"3",@"2",@"3"];
    }else if (tableView==self.repairTableView){
        sectionView.titleAry=self.sectionAry[1];
    }else if (tableView==self.partTableView){
        sectionView.titleAry=self.sectionAry[2];
    }
    return sectionView;
}
#pragma mark --HJRepairGroupHeaderViewDelegate
-(void)repairGroupHeaderView:(HJRepairGroupHeaderView *)repairGroupHeaderView changeRepairtCarType:(NSString *)carType
{
    self.requestModel.MODEL_LABOUR_CODE=carType;
}
-(void)repairGroupHeaderView:(HJRepairGroupHeaderView *)repairGroupHeaderView changeRepairtName:(NSString *)name{
    self.requestModel.PACKAGE_NAME=name;
}
-(void)repairGroupHeaderView:(HJRepairGroupHeaderView *)repairGroupHeaderView changeRepairtCode:(NSString *)code
{
    self.requestModel.PACKAGE_CODE=code;
}
#pragma mark --HJRepairtGroupMainCellDelegate
-(void)repairtGroupMainCell:(HJRepairtGroupMainCell *)repairtGroupMainCell clickSelectGroup:(HJRepairtGroupTM_PACKAGEModel *)TM_PACKAGEModel isSelect:(BOOL)status
{

    if (status) {
        //增加
        //维修组合
        for (HJRepairtGroupTM_PACKAGE_LABOURModel*TM_PACKAGE_LABOURModel in self.groupModel.TM_PACKAGE_LABOUR) {
            if ([TM_PACKAGE_LABOURModel.PACKAGE_CODE isEqualToString:TM_PACKAGEModel.PACKAGE_CODE]) {
                [self.repairtDataAry addObject:TM_PACKAGE_LABOURModel];
            }
        }
        //维修配件
        for (HJRepairtGroupTM_PACKAGE_PARTModel*TM_PACKAGE_PARTModel in self.groupModel.TM_PACKAGE_PART) {
            if ([TM_PACKAGE_PARTModel.PACKAGE_CODE isEqualToString:TM_PACKAGEModel.PACKAGE_CODE]) {
                [self.partsDataAry addObject:TM_PACKAGE_PARTModel];
            }
        }
        
        //保养车型
        for (HJRepairtGroupTM_PACKAGE_MODELModel*TM_PACKAGE_MODELModel in self.groupModel.TM_PACKAGE_MODEL) {
            if ([TM_PACKAGE_MODELModel.PACKAGE_CODE isEqualToString:TM_PACKAGEModel.PACKAGE_CODE]) {
                [self.modelDataAry addObject:TM_PACKAGE_MODELModel];
            }
        }
        
        //保养车辆
        for (HJRepairtGroupTM_PACKAGE_VEHICLEModel*TM_PACKAGE_VEHICLEModel in self.groupModel.TM_PACKAGE_MODEL) {
            if ([TM_PACKAGE_VEHICLEModel.PACKAGE_CODE isEqualToString:TM_PACKAGEModel.PACKAGE_CODE]) {
                [self.vehicleAry addObject:TM_PACKAGE_VEHICLEModel];
            }
        }
        
        
    }else{
        //移除
        //维修项目
        for (HJRepairtGroupTM_PACKAGE_LABOURModel*TM_PACKAGE_LABOURModel in self.groupModel.TM_PACKAGE_LABOUR) {
            if ([TM_PACKAGE_LABOURModel.PACKAGE_CODE isEqualToString:TM_PACKAGEModel.PACKAGE_CODE]) {
                [self.repairtDataAry removeObject:TM_PACKAGE_LABOURModel];
            }
        }
        
        //维修配件
        for (HJRepairtGroupTM_PACKAGE_PARTModel*TM_PACKAGE_PARTModel in self.groupModel.TM_PACKAGE_PART) {
            if ([TM_PACKAGE_PARTModel.PACKAGE_CODE isEqualToString:TM_PACKAGEModel.PACKAGE_CODE]) {
                [self.partsDataAry removeObject:TM_PACKAGE_PARTModel];
            }
        }
        //保养车型
        for (HJRepairtGroupTM_PACKAGE_MODELModel*TM_PACKAGE_MODELModel in self.groupModel.TM_PACKAGE_MODEL) {
            if ([TM_PACKAGE_MODELModel.PACKAGE_CODE isEqualToString:TM_PACKAGEModel.PACKAGE_CODE]) {
                [self.modelDataAry removeObject:TM_PACKAGE_MODELModel];
            }
        }
    }
    //保养车辆
    for (HJRepairtGroupTM_PACKAGE_VEHICLEModel*TM_PACKAGE_VEHICLEModel in self.groupModel.TM_PACKAGE_MODEL) {
        if ([TM_PACKAGE_VEHICLEModel.PACKAGE_CODE isEqualToString:TM_PACKAGEModel.PACKAGE_CODE]) {
            [self.vehicleAry removeObject:TM_PACKAGE_VEHICLEModel];
        }
    }
    
    [self.mainTableView reloadData];
    [self.repairTableView reloadData];
    [self.partTableView reloadData];
}
#pragma mark --HJRepairGroupSectionViewDelegate
-(void)repairGroupSectionView:(HJRepairGroupSectionView *)repairGroupSectionView clickBtn:(UIButton *)btn
{
    if (!contentCon)
    {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
        contentCon.delegate = self;
    }
    contentCon.btnSender=btn;
    
    popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:222 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    
    [popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [popCon setPopoverContentSize:CGSizeMake(btn.frame.size.width, 280)];
    
    [popCon presentPopoverFromRect:CGRectMake(40, 15, 70, 20) inView:btn permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    NSMutableArray*source=[NSMutableArray array];
    if ([btn.currentTitle isEqualToString:@"工时单价"]){
        for (HJCommonModel*model in self.labourPrices) {
            [source addObject:model.NAME];
        }
    }
    contentCon.list = source;
    [contentCon.myTableView reloadData];
}
#pragma mark --ContentViewControllerDelegate
//弹出的回调方法
-(void)selectDelegate:(NSInteger)row btn:(UIButton *)btn
{        [btn setTitle:@"工时单价" forState:UIControlStateNormal];
    if ([btn.currentTitle isEqualToString:@"工时单价"]){
        for (HJRepairtGroupTM_PACKAGE_LABOURModel*TM_PACKAGE_LABOURModel in self.repairtDataAry) {
            TM_PACKAGE_LABOURModel.LABOUR_PRICE=[self.labourPrices[row] NAME];
            
            TM_PACKAGE_LABOURModel.LABOUR_AMOUNT=[NSString stringWithFormat:@"%.2f",[TM_PACKAGE_LABOURModel.LABOUR_PRICE floatValue]*[TM_PACKAGE_LABOURModel.STD_LABOUR_HOUR floatValue]];
        }
        [self.repairTableView reloadData];
    }
    
    //清空数据，退出控件
    [popCon dismissPopoverAnimated:YES];
    popCon = nil;
}
@end
